import { defineStore } from 'pinia'
import { ref } from 'vue'

export default defineStore('darkMode', () => {
  const isDark = ref<boolean>(false)
  const switchDark = () => isDark.value = !isDark.value
  const setDark = (val: boolean) => isDark.value = val
  return { isDark, switchDark, setDark }
}, {
  persist: {
    storage: {
      getItem: key => uni.getStorageSync(key),
      setItem: (key, value) => uni.setStorageSync(key, value)
    }
  }
})